﻿<Window x:Class="WpfTriggers.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="366" Width="814">
    <Grid>
        <TextBox Height="23" HorizontalAlignment="Left" Margin="32,31,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" >
            <TextBox.Style>
                <Style TargetType="TextBox">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="Gold" />
                            <Setter Property="BorderThickness" Value="3" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsFocused" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="Red" />
                        </MultiTrigger>
                    </Style.Triggers>
                </Style>
            </TextBox.Style>
        </TextBox>
 
        <TextBox Height="30" Width="100" HorizontalAlignment="Stretch"  Margin="32,85,660,0" Name="textBox2" VerticalAlignment="Top"  >
            <TextBox.Style>
                <Style TargetType="TextBox">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource Self}}" Value="disabled">
                            <Setter Property="UIElement.IsEnabled" Value="False" />
                        </DataTrigger>
                        <MultiDataTrigger >
                            <MultiDataTrigger.Conditions>
                                <Condition  Binding="{Binding Path=Width,RelativeSource={RelativeSource Self}}" Value="100"  />
                                <Condition  Binding="{Binding Path=Height,RelativeSource={RelativeSource Self}}" Value="30" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="Red" />
                        </MultiDataTrigger>
                    </Style.Triggers>
                    <Setter Property="Control.Foreground" Value="{Binding Path=Text, RelativeSource={RelativeSource Self}}" />
                </Style>
            </TextBox.Style>
        </TextBox>
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="239,30,0,0" Name="button1" VerticalAlignment="Top" Width="75" >
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <BeginStoryboard>
                        <Storyboard  Storyboard.TargetProperty="Width">
                            <DoubleAnimation From="100" To="200" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Button.Triggers>
        </Button>
        <TextBox Height="30" HorizontalAlignment="Stretch" Background="Yellow" Margin="214,85,478,0" Name="textBox3" VerticalAlignment="Top" Width="100">
            <TextBox.Style>
                <Style TargetType="TextBox">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver"  Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation  To="Red" Duration="00:00:0.500"  Storyboard.TargetProperty="(TextBox.Background).(SolidColorBrush.Color)" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation  To="Transparent" Duration="00:00:0.500"  Storyboard.TargetProperty="(TextBox.Background).(SolidColorBrush.Color)" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </Style.Triggers>
                    <Setter Property="Control.Foreground" Value="{Binding Path=Text, RelativeSource={RelativeSource Self}}" />
                </Style>
            </TextBox.Style>
        </TextBox>
    </Grid>
</Window>
